package com.ktwlsoft.archivemanage.controller;

import com.ktwlsoft.archivemanage.domain.business.businessService.AdNotifyService;
import com.ktwlsoft.archivemanage.domain.dao.entity.AdNotify;
import com.ktwlsoft.archivemanage.payload.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "小程序业务通知")
@RestController
@RequestMapping("/adNotifyForMini")
public class AdNotifyForMinController {
    private final AdNotifyService adNotifyService;

    public AdNotifyForMinController(AdNotifyService adNotifyService) {
        this.adNotifyService = adNotifyService;
    }


    @ApiOperation("查看通知")
    @GetMapping("/getNotify")
    public ResponseEntity<?> getNotify(@ApiParam("通知id") @RequestParam Long id) {
        return ResponseEntity.ok(Result.ok(adNotifyService.getById(id)));
    }

    @ApiOperation("查询列表")
    @GetMapping("/getAll")
    public ResponseEntity<?> getAll(
            @ApiParam("状态") @RequestParam(required = false) AdNotify.State state,
            @ApiParam("操作人") @RequestParam(required = false) String operatorId,
            @ApiParam("操作时间起") @RequestParam(required = false) String operateFrom,
            @ApiParam("操作时间止") @RequestParam(required = false) String operateTo,
            @ApiParam("关键字") @RequestParam(required = false) String keywords,
            @ApiParam("pn") @RequestParam Integer pn,
            @ApiParam("pageSize") @RequestParam Integer pageSize
    ){
        return ResponseEntity.ok(Result.ok(adNotifyService.findAll(pn, pageSize, state, operateFrom, operateTo, operatorId, keywords)));
    }
}
